package com.yzh.oop2;

/**
 * @author 于振晗
 * @title: Cat
 * @description: TODO 猫类
 * @date 2020年08月25日
 * @path com.yzh.animal
 */
public class Dog extends Animal {
    private String nickName;//昵称

    public Dog() {
    }

    public Dog(String color, int age, String nickName) {
        super(color, age);
        this.nickName = nickName;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "nickName='" + nickName + '\'' +
                "} " + super.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;

        Dog dog = (Dog) o;

        return nickName != null ? nickName.equals(dog.nickName) : dog.nickName == null;
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + (nickName != null ? nickName.hashCode() : 0);
        return result;
    }
}
